/*
 * To change this template, choose Tools | Templates
 * and open the template in the editor.
 */
package com.rie.test;

import java.rmi.ConnectException;
import java.rmi.Naming;
import java.rmi.RemoteException;
import java.util.logging.Level;
import java.util.logging.Logger;
import javax.ws.rs.GET;
import javax.ws.rs.Path;
import javax.ws.rs.PathParam;
import javax.ws.rs.Produces;
import rie.api.SystemeInfoFactory;
import rie.model.SystemeInfo;

/**
 *
 * @author Habib, Arnaud
 */
@Path(value = "/sysInfo")
public class monitoringService {

    @GET
    @Path(value = "/{serveur}")
    @Produces(value = {"text/xml"})
    public SystemeInfo getSystemeInfo(@PathParam(value = "serveur") String serveur) {
        SystemeInfo si = null;
        try {
            si = ((SystemeInfoFactory) Naming.lookup("//" + serveur + "/SystemeInfoFactoryServer")).createSysteme();
            si.setServeur(serveur);

        } catch (Exception ex) {
            si = new SystemeInfo("La connexion vers le serveur a échoué.");
            Logger.getLogger(monitoringService.class.getName()).log(Level.SEVERE, "La connexion vers le serveur a échoué.");
        }
        return si;
    }
}
